package com.newmuis.open.codeeval.easy;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

/**
 * CodeEval.com > Easy Challenges > Lowercase
 * 
 * Description:
 * 
 * Given a string write a program to convert it into lowercase.
 * 
 * Input sample:
 * 
 * The first argument will be a text file containing sentences, one per line. You can assume all
 * characters are from the english language. e.g.
 * 
 * HELLO CODEEVAL
 * This is some text
 * 
 * Output sample:
 * 
 * Print to stdout, the lowercase version of the sentence, each on a new line.
 * e.g.
 * 
 * hello codeeval
 * this is some text
 * 
 * @author Jonathan Newmuis (jon@newmuis.com)
 * @category easy
 * 
 */
public class lowercase {
	/**
	 * @param args should contain only one CLI argument: the path to an input file which specifies
	 *            the input in the defined format.
	 * @throws IOException if there is a problem reading the given input file.
	 */
	public static void main(final String[] args) throws IOException {
		// Verify input argument length.
		if (args.length < 1) {
			throw new RuntimeException("Must specify input file path.");
		} else if (args.length > 1) {
			throw new RuntimeException("Illegal input arguments specified.");
		}

		// Read file from specified path.
		final BufferedReader reader = new BufferedReader(new FileReader(new File(args[0])));
		String line;

		while ((line = reader.readLine()) != null) {
			// This is almost too easy...
			System.out.println(line.toLowerCase());
		}
	}
}
